package com.tubi.String;
//String[] split(String regex) ：根据传入的字符串作为规则进行切割
import com.tubi.domain.Student;

import java.util.Scanner;

public class 切割字符串 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入学生信息");
        String stuInfo = sc.nextLine();
        //根据逗号切割字符串
        String[] split = stuInfo.split(",");
        System.out.println(split[0]);
        System.out.println(split[1]);
        Student st = new Student();
        st.setName(split[0]);
        st.setAge(split[1]);
        System.out.println(st.getAge());
        System.out.println(st.getName());
    }
}
